package com.assessment.servermanager.controller;

import com.assessment.servermanager.commen.controller.BaseController;
import com.assessment.servermanager.commen.entity.AjaxResult;
import com.assessment.servermanager.commen.entity.PageQuery;
import com.assessment.servermanager.commen.page.TableDataInfo;
import com.assessment.servermanager.entity.TbAdvice;
import com.assessment.servermanager.entity.bo.TbAdviceBo;
import com.assessment.servermanager.entity.vo.TbAdviceVo;
import com.assessment.servermanager.service.ITbAdviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author jiajia
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/advice")
public class TbAdviceController extends BaseController {
    @Autowired
    private ITbAdviceService tbAdviceService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo<TbAdviceVo> list(TbAdviceBo tbAdviceBo, PageQuery pageQuery) {
        return tbAdviceService.selectTbAdviceList(tbAdviceBo,pageQuery);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbAdvice tbAdvice) {
      /*  List<TbAdvice> list = tbAdviceService.selectTbAdviceList(new TbAdviceQC());
        ExcelUtil<TbAdvice> util = new ExcelUtil<TbAdvice>(TbAdvice.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");*/
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(tbAdviceService.selectTbAdviceById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PostMapping
    public AjaxResult add(@RequestBody TbAdvice tbAdvice) {
        return toAjax(tbAdviceService.insertTbAdvice(tbAdvice));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TbAdvice tbAdvice) {
        return toAjax(tbAdviceService.updateTbAdvice(tbAdvice));
    }

    /**
     * 删除【请填写功能名称】
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tbAdviceService.deleteTbAdviceByIds(ids));
    }
}
